package com.miukoo.aikao.qpaper.controller;


import com.miukoo.aikao.core.dtos.ApiResult;
import com.miukoo.aikao.core.dtos.BaseIdReqDto;
import com.miukoo.aikao.core.utils.ApiUtils;
import com.miukoo.aikao.qpaper.dto.ext.PaperQuestionDetailDto;
import com.miukoo.aikao.qpaper.dto.response.ExamResultRespDto;
import com.miukoo.aikao.qpaper.service.PaperService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
* <p>
* 试卷控制器
* </p>
*
* @author 聪明笨狗
* @since 2020-05-25 16:33
*/
@Api(tags={"试卷"})
@RestController
@RequestMapping("/exam/api/paper/admin")
public class PaperAdminController {

    @Autowired
    private PaperService baseService;

    /**
     * 批量删除
     * @param reqDto
     * @return
     */
    @ApiOperation(value = "试卷详情")
    @RequestMapping(value = "/revise-result", method = { RequestMethod.POST})
    public ApiResult<ExamResultRespDto> paperResult(@RequestBody BaseIdReqDto reqDto) {
        //根据ID删除
        ExamResultRespDto respDto = baseService.paperResult(reqDto.getId(),true);
        return ApiUtils.success(respDto);
    }


    /**
     * 提交阅卷
     * @param reqDto
     * @return
     */
    @ApiOperation(value = "提交阅卷")
    @RequestMapping(value = "/revise-paper", method = { RequestMethod.POST})
    public ApiResult<PaperQuestionDetailDto> reviewPaper(@RequestBody ExamResultRespDto reqDto) {
        baseService.reviewPaper(reqDto);
        return ApiUtils.success();
    }
}
